<?php
/**
 * Object Relational Persistence Mapping Class for table: employee_type
 *
 * @package	com.athena
 * @author	LHV
 */
class EmployeeType extends ORDataObject {

	/**#@+
	 * Fields of table: employee_type mapped to class members
	 */
	var $employee_type_id		= '';
	var $parent_id		= '';
	var $vi_name	=	'';
	var $en_name	=	'';
	/**#@-*/

	const GREATEST_PARENT_ID = 0;
	const CASHIER_ID = 5;
	const DOCTOR_ID = 1;
	const TECHNICAN_ID = 3;
	const NURSING_ID = 2;
	
	/**
	 * DB Table
	 */
	var $_table = 'employee_type';

	/**
	 * Primary Key
	 */
	var $_key = 'employee_type_id';
	
	/**
	 * Internal Name
	 */
	var $_internalName = 'EmployeeType';

	/**
	 * Handle instantiation
	 */
	function EmployeeType() {
		parent::ORDataObject();
	}

	function listAllParentType() {
		$field	=	L10nHelper::getLocale();
		$field	=	L10nHelper::changeField($field,"name");
		$ds = new Datasource_sql();
		$sql = array(
			'cols'	=> "employee_type_id, $field as name",
			'from'	=> "$this->_table",
			'where'	=> "parent_id = " . self::GREATEST_PARENT_ID,
			'orderby'	=> 'name'
		);
		$ds->setup($this->_db, $sql);
		return $ds->toArray('employee_type_id', 'name');
	}
	
	function getAll(){
		$ds = new Datasource_sql();
		$locale = L10nHelper::getLocale();
		$locale = L10nHelper::changeField($locale, "name");
		$sql = array(
				'cols'	=> "employee_type_id,$locale as name",
				'from'	=> "$this->_table",
		);
		$ds->setup($this->_db, $sql);
		return $ds->toArray('employee_type_id', 'name');
	}

}
?>
